<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>edit</title>
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-col-lg-offset3 layui-col-lg6">
        <form action="" class="layui-form" >
        <div id="editdiv">

            <div class="layui-form-item">
                <label class="layui-form-label">ID：</label>
            <div class="layui-input-block">
                <input type="text" id="id" name="id" lay-verify="name" autocomplete="off" disabled="disabled" class="layui-input" >
            </div>
               </div>
               <div class="layui-form-item">
               <label class="layui-form-label">登录名：</label>
            <div class="layui-input-block">
                <input type="text" id="username" name="username" lay-verify="name" autocomplete="off" placeholder="请输入要更改的名称" class="layui-input" >
            </div>
     </div>
            <div class="layui-form-item">
           <label class="layui-form-label">新密码：</label>
           <div class="layui-input-block">
                 <input type="text" id="password" name="password" autocomplete="off" placeholder="请输入新密码" class="layui-input" >
              </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
        </form>
    </div>
</div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;
        var s = window.decodeURIComponent(location.search.slice(1).split("=")[1]);
        var s1 = JSON.parse(s);
        $("#id").val(s1.id);
        $("#username").val(s1.username);
        $("#password").val(s1.password);

        //监听提交
        form.on('submit(demo1)', function (data) {
            //请求添加接口
            $.post("/admin/updateAdmin",data.field,function(res){
                if(res.code==10000){
                    //修改成功
                    window.parent.location.href="/listadmin.html";
                }else{
                    //添加失败
                    layer.alert("修改失败", {
                        title: '亲，修改失败，请检查网络'
                    });
                    // window.parent.location.href="/listadmin.html";
                }
            })
            return false;
        });
    });
</script>
</body>
</html>